import { _decorator, Component, Node,EventTarget } from 'cc';
const { ccclass, property } = _decorator;

// 事件系统引入，同时实例化事件对象
const eventTarget = new EventTarget()

@ccclass('Game')
export class Game extends Component {
    private user_exp = 0;
    onLoad(){
        // 监听增加经验的事件
        eventTarget.on('increase_exp',(exp)=>{
            this.user_exp += exp;
            console.log(`获得${exp}经验,当前经验${this.user_exp}`);
        },this)
    }
    start() {
        // 触发增加经验
        const EXP = 5
        eventTarget.emit('increase_exp', EXP)
        


    }

    update(deltaTime: number) {
        
    }
}


